package org.ym.database.hibernate.utils;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;
import org.ym.basic.SnowflakeIdWorker;

import java.io.Serializable;

/**
 * @author ym
 */
@Slf4j
public class SnowflakeIdGenerator implements IdentifierGenerator {
    @Override
    public Serializable generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws HibernateException {
        return SnowflakeIdWorker.genIdByLong();
    }
}
